<template>
  <view class="demo-container">
    <!-- 基础用法 -->
    <view class="demo-block">
      <view class="demo-block__title">基础用法</view>
      <view class="demo-block__content">
        <fu-field
          v-model:value="value1"
          label="数字键盘"
          readonly
          placeholder="点击输入"
          type="digit"
          @click="show1 = true"
        />
        <fu-keyboard
          v-model:show="show1"
          @input="onInput1"
          @delete="onDelete1"
        />
      </view>
    </view>
    
    <!-- 身份证键盘 -->
    <view class="demo-block">
      <view class="demo-block__title">身份证键盘</view>
      <view class="demo-block__content">
        <fu-field
          v-model:value="value2"
          label="身份证号"
          readonly
          placeholder="点击输入"
          @click="show2 = true"
        />
        <fu-keyboard
          v-model:show="show2"
          type="idcard"
          @input="onInput2"
          @delete="onDelete2"
        />
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      show1: false,
      show2: false,
      value1: '',
      value2: ''
    }
  },
  methods: {
    onInput1(key) {
      this.value1 = this.value1 + key
    },
    onDelete1() {
      this.value1 = this.value1.slice(0, -1)
    },
    onInput2(key) {
      this.value2 = this.value2 + key
    },
    onDelete2() {
      this.value2 = this.value2.slice(0, -1)
    }
  }
}
</script>

<style lang="scss" scoped>
.demo-container {
  padding: 20rpx;
}

.demo-block {
  margin-bottom: 30rpx;
  
  &__title {
    margin-bottom: 20rpx;
    font-size: var(--fu-font-size-lg);
    color: var(--fu-text-color);
  }
  
  &__content {
    background-color: #fff;
    border-radius: var(--fu-radius-base);
    overflow: hidden;
  }
}
</style> 